<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ include file="../include/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  		<%@ include file="../include/jsCss.jsp" %>
  		<script language="javascript" src="${webUrl}/js/jquery.form.js"></script>

		<title>文件上传</title> 

<style>
 	bgcolor : #DFE8F6
</style>
	</head>

	<body>
		<div align="left">
			<form id="htmlForm" action="${webUrl}/images!upload.html" enctype="multipart/form-data" method="post" onsubmit="return imagevalidate()"> 
				<input type="submit" value="上传"/>
				<input type="hidden" value="${width}"  name="width" id="width">
				<input type="hidden" value="${height}"  name="height" id="height">
				上传图片1：<input type="file" name="upload" id="folderField" onchange="selectFile();" size="10">
				上传图片2：<input type="file" name="upload2" id="folderField2" onchange="selectFile();" size="10">
				上传图片3：<input type="file" name="upload3" id="folderField3" onchange="selectFile();" size="10">
				<span style="font-size: 12px;" >&nbsp;&nbsp;<font color="red">最大400k</font></span>
				<br/><img id="imgField" src="${webUrl}${imagePath}" width="200" height="200"/>&nbsp;&nbsp;
					<img id="imgField" src="${webUrl}${imagePath2}" width="200" height="200"/>&nbsp;&nbsp;
					<img id="imgField" src="${webUrl}${imagePath3}" width="200" height="200"/>
			</form>
		</div>
	</body>
</html>
<script type="text/javascript"> 
		//针对chrome浏览器
	  var lastFile='';
	  var nowFile='';
		
 	  function selectFile(){
 		 var folderField = document.getElementById('folderField').value;
 		 alert(folderField);
 	  	 var folderField2 = document.getElementById('folderField2').value;
 	  	 var folderField3 = document.getElementById('folderField3').value;
 	  	 if (folderField == "" && folderField2 == "" && folderField3 == "") {
 	  		  
 		 	  return false;
 	     }else{
 	    	 	
		 		nowFile=$('#folderField').val();
		 		alert(nowFile);
				$('#htmlForm').ajaxForm(function(data) {
					//alert('2');
					//var dataObj = eval("(" + data + ")");
					
					//alert(pagePath);
					
					//if(!dataObj.success){
					//	alert(dataObj.msg);
					//	return ;
					//}
					//var pagePath = dataObj.pagePath;
					if (data == 0) {
						document.location.reload();
					}
					//$('#imgField').attr("src",data);
					
				});
					
		 }
 	 }
 	  
 	  function imagevalidate() {
 	  	 var folderField = document.getElementById('folderField').value;
 	  	 var folderField2 = document.getElementById('folderField2').value;
 	  	 var folderField3 = document.getElementById('folderField3').value;
 	  	 if (folderField ==  "" && folderField2 == "" && folderField3 == "") {
 		   		alert('请选择上传的图片');
 		   		return false;
 		 }
 	  }
</script>